const logger = require('./utils').getLogger(__filename);
const WebSocketAwait = require('ws-await');
const config = require('config')
const { host, port } = config.get('mcs')
const { MessageRouter } = require('./MessageRouter');
const wss = new WebSocketAwait.Server({
	port,
	host
});

wss.on('connection', ws => {
	logger.info(`client is connection!`)
	ws.on('messageAwait', (msg, id) => {
		MessageRouter(msg).then(ret => ws.resAwait(ret, id)).catch(ret => ws.resAwait(ret, id))
	});
});


